import React from 'react';
import { fetchUserTaskInfo } from '../Employee/service';

// 考核员工的考核信息
const useUserTaskInfo = query => {
    const [resData, setResData] = React.useState([]);
    const [loading, setLoading] = React.useState(true);

    const fetchData = async () => {
        setLoading(true);
        const { data, code } = (await fetchUserTaskInfo(query)) || {};

        if (code === 10000) {
            setResData(data);
        }

        setLoading(false);
    };

    React.useEffect(() => {
        fetchData();
    }, [query]);

    return [loading, resData];
};

export default useUserTaskInfo;
